<script setup>
import { ref, provide } from 'vue';
import { RouterLink,RouterView } from 'vue-router';
import router from '@/router';
//反馈信息组件
import DialogApi from "@/components/prompt/dialog-api.vue";
import LoadingApi from "@/components/prompt/loading-api.vue";
import MessageApi from "@/components/prompt/message-api.vue";
import NotificationApi from "@/components/prompt/notification-api.vue";
import { darkTheme } from 'naive-ui'
//全局方法注册
let darkThemeSet = ref(undefined);
//深浅色模式设置
function dark(darkSet=false) {
  if (darkSet){
    darkThemeSet.value = darkTheme
  }else {
    darkThemeSet.value=undefined
  }
}
function toPage(pageName='/',prs={},self=true) {
  if (pageName.length>1){
    let nextPage = '/'+pageName
    console.log(self)
    if (self){
      router.push({
        path: nextPage,
        query: prs,
      })
    }else {
      const routeUrl = router.resolve({
        path: nextPage,
        query: prs,
      })
      window.open(routeUrl.href,'_blank')
    }
  }else {
    router.push(pageName)
  }
}

provide('toPage', { toPage })
provide('dark',{ dark })
</script>

<template>
  <n-config-provider :theme="darkThemeSet">
    <!--  设置加载状态条-->
    <n-loading-bar-provider>
      <LoadingApi />
    </n-loading-bar-provider>
    <!--  设置提示信息-->
    <n-message-provider>
      <MessageApi />
    </n-message-provider>
    <!--  设置通知消息-->
    <n-notification-provider>
      <NotificationApi />
    </n-notification-provider>
    <!--  对话框设置-->
    <n-dialog-provider>
      <DialogApi/>
    </n-dialog-provider>
    <n-scrollbar trigger="hover">
      <RouterView />
    </n-scrollbar>
  </n-config-provider>
</template>

<style scoped>

</style>
